package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.itheima.dao.VisitDao;
import com.itheima.domain.Visit;
import com.itheima.service.VisitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * ClassName:VisitServiceImpl
 * Package:com.itheima.service.impl
 * Description:
 * Date:2020/3/24 14:18
 * User: snow
 */
@Service
@Transactional
public class VisitServiceImpl implements VisitService {

	@Autowired
	private VisitDao visitDao;

	@Override
	public List<Visit> findAll()throws Exception {
		return visitDao.findAll();
	}

	@Override
	public List<Visit> findAll(int page, int size) throws Exception {
		/**
		 * //参数配置
		 * pageNum 页码值   pageSize  每页最大值
		 */
		PageHelper.startPage(page,size);
		return visitDao.findAll();
	}

	/**
	 * 按条件获取拜访记录
	 * @param page
	 * @param size
	 * @param visit
	 * @return
	 * @throws Exception
	 */
	@Override
	public List<Visit> findAll(int page, int size,Visit visit) throws Exception {
		/**
		 * //参数配置
		 * pageNum 页码值   pageSize  每页最大值
		 */
		PageHelper.startPage(page,size);
		return visitDao.findSome(visit);
	}

	@Override
	public Visit findById(String id) {
		return visitDao.findById(id);
	}

	@Override
	public void save(Visit visit) {
		visitDao.save(visit);
	}

	@Override
	public void delete(String id) {
		visitDao.delete(id);
	}
}
